import axios from '@/components/util/AxiosPlugin';
import GlobalUtil from '@/components/util/GlobalUtil';

/** 查询数据字典二级目录 */
export function queryPublishDictByType(setResult) {
  return axios.get('/publish-project/dictionary/queryByType?parentType=00000,99999').then(data => setResult(data)).catch(e => {GlobalUtil.catchError(e)});
}

/** 分页查询数据字典数据 */
export function queryPublishDictByPage(params, setResult) {
  return axios.post('/publish-project/dictionary/queryByPage', params).then(data => setResult(data)).catch(error => GlobalUtil.catchError(error));
}

/** 新增数据字典 */
export function addDictionary(params, callback) {
  return axios.post('/publish-project/dictionary/add', params).then(() => {GlobalUtil.sucessNotify(); callback();}).catch(error => GlobalUtil.catchError(error));
}

/** 更新数据字典 */
export function updateDictionary(params, callback) {
  return axios.post('/publish-project/dictionary/update', params).then(() => {GlobalUtil.sucessNotify(); callback();}).catch(error => GlobalUtil.catchError(error));
}
